#include <bits/stdc++.h>

using namespace std;

class StockPrice
{
public:
    StockPrice()
    {
    }

    void update(int timestamp, int price)
    {
        cur = max(timestamp, cur);
        auto it = m.find(timestamp);
        if (it != m.end())
        {
            s.erase(s.find(it->second));
        }
        m[timestamp] = price;
        s.insert(price);
    }

    int current()
    {
        return m[cur];
    }

    int maximum()
    {
        return *s.rbegin();
    }

    int minimum()
    {
        return *s.begin();
    }

private:
    unordered_map<int, int> m;
    int cur = 0;
    multiset<int> s;
};